import {Component, OnInit, Input, OnChanges} from '@angular/core';
import {NzMessageService} from "ng-zorro-antd";
import {FetchService} from "../../../core/net/fetch.service";
import {FormBuilder, FormGroup} from "@angular/forms";

@Component({
  selector: "app-glc-panel",
  templateUrl: "./glc-panel.component.html",
  styleUrls: ["./glc-panel.component.scss"]
})
export class GlcPanelComponent implements OnInit {
  dmTableData = [];
  total: number;
  pageNum = 1;
  pageSize = 13;
  loading = false;
  searchForm: FormGroup;

  constructor(
    private message: NzMessageService,
    private fetchService: FetchService,
    private fb: FormBuilder
  ) {
    this.searchForm = this.fb.group({
      key: ['']
    });
  }

  ngOnInit() {
    this.queryInfo();
  }

  queryInfo(reset: boolean = false): void {
    if (reset) {
      this.pageNum = 1;
    }
    this.loading = true;
    this.fetchService.post<any>("base/wrsBrwaterCannal/listLast", {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        key: this.searchForm.value.key
    }).subscribe(res => {
        this.loading = false;
        this.total = res.total;
        this.dmTableData = res.list;
      });
  }

}
